package org.example.demo.service;

import org.example.demo.dao.UserDao;
import org.example.demo.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName: Fsk App
 * @Copyright: com.fsk
 * @Version: 1.0.0
 * @Author: chenming2
 * @UpdateTime: 2/28/2022
 * @Describe: XXXXXXX.
 */
@Service
public class UserService {
    @Autowired
    private UserDao userDao;

    public void transfer(Double money) {
        // 编程式事务管理
        try {
            // 开启事务

            // 业务操作
            userDao.plus(money, "foo");
            userDao.minus(money, "bar");

            // 提交
        } catch (Exception e) {
            // 回滚
        }

    }
}
